package com.webdemo04.action;

import java.sql.Connection;
import java.sql.PreparedStatement;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;
import com.webdemo04.util.DBHandler;
@Namespace(value="/jsp")
@Action(value="DeleteUser",results={@Result(location="QueryUser",type="redirectAction")})
public class DeleteUser extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private int id;
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Override
	public String execute() throws Exception {
		Connection conn = DBHandler.newInstance().getConnection();
		String sql = "delete from annotation01_user where id=?";
		PreparedStatement pstmt = conn.prepareStatement(sql);
		pstmt.setInt(1, id);
		pstmt.executeUpdate();
		return SUCCESS;
	}

}
